<?php


namespace addon\hotel\hotel\controller;

use app\model\hotel\hotel as hotelModel;
use app\model\system\Address as AddressModel;
use app\model\web\Config as ConfigModel;
/**
 * 跳转页
 */
class Hotel extends BaseHotel
{

    /**
     * 编辑城市分站
     */
    public function config()
    {
        $condition = array(
            ["hotel_id", "=", $this->hotel_id],
        );
        $website_model = new hotelModel();
        if (request()->isAjax()) {

            $data = [
                'hotel_name' => input('hotel_name', ''),
                'hotel_img' => input('hotel_img', ''),
                'telphone' => input('telphone', ''),
                'status' => input('status', ''),
                'province_id' => input('province_id', ''),
                'city_id' => input('city_id', ''),
                'district_id' => input('district_id', ''),
                'address' => input('address', ''),
                'full_address' => input('full_address', ''),
                'longitude' => input('longitude', ''),
                'latitude' => input('latitude', ''),

                'traffic' => input('traffic', ''),
                'hotel_level' => input('hotel_level', 0),
                'business_license' => input('business_license', ''),
                'start_time' => input('start_time', ''),
                'end_time' => input('end_time', ''),
                'images' => input('images', ''),
                'video_url' => input('video_url', ''),
                'introduce' => input('introduce', ''),
                'label_format' => input('label_format', ''),
                'equipment_format' => input('equipment_format', ''),

                'front_pic_id_card' => input('front_pic_id_card', ''),
                'reverse_pic_id_card' => input('reverse_pic_id_card', ''),
                'id_card_name' => input('id_card_name', ''),
                'id_card_number' => input('id_card_number', ''),
                'id_card_type' => input('id_card_type', ''),
                'id_card_start_time' => input('id_card_start_time', ''),
                'id_card_end_time' => input('id_card_end_time', ''),
                'account_holder' => input('account_holder', ''),
                'bank_number' => input('bank_number', ''),
                'bank_type' => input('bank_type', ''),

                'free_cancel_time' => input('free_cancel_time', ''),

                'refund_rule' => input('refund_rule', ''),
            ];

            //$condition[] = [ 'hotel_id', '=', $this->hotel_id ];
            $res = $website_model->editHotel($data, $condition);
            return $res;
        } else {
            //查询省级数据列表
            $address_model = new AddressModel();
            $list = $address_model->getAreaList([["pid", "=", 0], ["level", "=", 1]]);
            $this->assign("province_list", $list["data"]);
            //门店信息
            $info_result = $website_model->getHotelInfo($condition);
            $this->assign("info", $info_result['data']);

            //获取地址key配置
            $config_model = new ConfigModel();
            $config = $config_model->getMapConfig();
            $this->assign('map_key', $config[ 'data' ][ 'value' ]);

            $id_card_type_list = $website_model->idCardType();

            $this->assign('id_card_type_list', $id_card_type_list);

            return $this->fetch('hotel/config', [], $this->replace);
        }
    }

}